<link rel="stylesheet" href="<?php echo base_url() ?>css/jquery.ui.all.min.css">
<script src="<?php echo base_url() ?>js/external/jquery.bgiframe-2.1.2.js"></script>
<script src="<?php echo base_url() ?>js/ui/jquery.ui.core.min.js"></script>
<script src="<?php echo base_url() ?>js/ui/jquery.ui.widget.min.js"></script>
<script src="<?php echo base_url() ?>js/ui/jquery.ui.mouse.min.js"></script>
<script src="<?php echo base_url() ?>js/ui/jquery.ui.button.min.js"></script>
<script src="<?php echo base_url() ?>js/ui/jquery.ui.draggable.min.js"></script>
<script src="<?php echo base_url() ?>js/ui/jquery.ui.position.min.js"></script>
<script src="<?php echo base_url() ?>js/ui/jquery.ui.dialog.min.js"></script>
<script>
    $(function() {
        $( "#dialog-confirm" ).dialog({
            resizable: false,
            height:600,
            width:600,
            modal: true,
            buttons: {
                "Benar": function() {
                    document.form_daftar_old.submit();
                },
                "Salah": function() {
                    $( this ).dialog( "close" );
                }
            },
            autoOpen : false
        });
    });    
    function check_nocic(){

        nama = $('.nama').val();
        nohp = $('.nohp').val();
        kelas = $('.kelas').val();
        if(nama==''){
            alert('Harap isi nama!!');
        }else if(nohp==''){
            alert('Harap isi no HP!!');
        }else if(kelas==-1){
            alert('Harap pilih kelas pelatihan');
        }else{
            data_post = {no_cic : $('#nocic').val()};
            if($('#nocic').val()==''){
                //document.form_daftar_new.submit();
                open_confirm();
            }else{
                $.ajax({
                    type : 'POST',
                    data: data_post,
                    url : '<?php echo base_url() ?>pendaftaran/daftar_con/check_no_cic',
                    dataType:'json',
                    success : function(data){
                        if(data['respon']){
                            open_confirm();
                        }else{
                            alert('No CIC yang anda masukkan sudah tidak dapat digunakan lagi untuk term ini');
                        }
                    }
                });
            }
        }
    }

    function open_confirm(){
        nama = $('.nama').val();
        nohp = $('.nohp').val();
        kelas = $('.kelas').val();
        
        $("#konfirm_nama").text(nama);
        $("#konfirm_nohp").text(nohp);
        $("#konfirm_kelas").text(kelas);
        $( "#dialog-confirm" ).dialog('open');
    }
</script>

<div id="dialog-confirm" title="Konfirmasi Data Peserta">

    <table ID="tabel-confirm" width="400" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td>
                <div>Nama Lengkap</div>
                <div id="konfirm_nama"></div>
            </td>
        </tr>
        <tr>
            <td>
                <div>No Handphone</div>
                <div id="konfirm_nohp"></div>
            </td>
        </tr>
        <tr>
            <td>
                <div>Mendaftar pada Pelatihan</div>
                <div id="konfirm_kelas"></div>
            </td>
        </tr>
<!--        <tr>
            <td>
                <div>Diskon</div>
                <div id="konfirm_diskon"></div>
            </td>
        </tr>-->
    </table>
</div>

<div class="beftabel">
    <form name="form_daftar_old" action="<?php echo base_url()?>pendaftaran/daftar_con/daftar_old_proses" method="post">
    <table border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td><table width="400" border="0" cellspacing="0" cellpadding="0">
                    <input name="id" type="hidden" class="field1" id="textfield" value="<?php echo $user['ID'];?>"/>
                    <tr>
                        <td class="namaform">Nama Lengkap</td>
                    </tr>
                    <tr>
                        <td><input name="nama" type="text" class="field1 nama" id="textfield" value="<?php echo $user['NAMA'];?>"/></td>
                    </tr>
                    <tr>
                        <td class="namaform">No Handphone</td>
                    </tr>
                    <tr>
                        <td><input  name="nohp" type="text" class="field1 nohp" id="textfield2" value="<?php echo $user['NO_TELP'];?>"/></td>
                    </tr>
                    <tr>
                        <td class="namaform">Mendaftar pada Pelatihan</td>
                    </tr>                 
                    <tr>
                        <td>
                            <?php
                            $script = 'class="field2 kelas" id="select"';
                            echo form_dropdown('kelas', $pelatihan, '', $script);
                            ?>
                        </td>
                    </tr> 
                    <tr>
                        <td class="namaform">Diskon yang Diperoleh</td>
                    </tr>                 
                    <tr>
                        <td>
                            <ul class="tabs">
                                <li><a href="#tab1">Dengan CIC Card</a></li>
                                <li><a href="#tab2">Tanpa CIC Card</a></li>
                            </ul>
                            <div class="tab_container">
                                <div id="tab1" class="tab_content">
                                    <input name="nocic" type="text" class="fieldy" id="nocic" value="<?php echo $peserta['NO_CIC_CARD']?>"/>
                                </div>
                                <div id="tab2" class="tab_content">
                                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                        <?php for ($i = 0; $i < count($diskon); $i++) { ?>
                                            <input id="diskon" type="checkbox" name="diskon[]" value="<?php echo $diskon[$i]['no'] ?>" /><?php echo $diskon[$i]['nama'] ?>
                                            <br/>
                                        <?php } ?>
                                    </table>
                                </div>
                            </div>
                        </td>
                    </tr>
                </table>
            </td>
            <td valign="top" class="jarak">&nbsp;</td>
            <td valign="top" class="tempatbutton">
                <input type="button" class="save" id="button" value="Save" onclick="check_nocic()"/>
            </td>
        </tr>
    </table>
    </form>    
</div>

</div>
</td>
<td class="b6"></td>
</tr>
<tr>
    <td class="b4"></td>
    <td class="b5">    <div class="footer2">Copyright &copy;2011 CIC Team | Credits</div></td>
    <td class="b6"></td>
</tr>
<tr>
    <td id="b7"></td>
    <td id="b8"></td>
    <td id="b9"></td>
</tr>
</table>
